package com.jiangore.config.log;

import ch.qos.logback.classic.ViewStatusMessagesServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Todo
 * @Author jiangtao
 * @CreateBy 2020-03-11 10:28 PM
 * @UpdateBy jiangtao
 * @Version v1.0
 */
@Configuration
public class LogbackConfig {

    @Bean
    public ServletRegistrationBean logbackServlet() {
        ServletRegistrationBean bean = new ServletRegistrationBean(new ViewStatusMessagesServlet());
        bean.addUrlMappings("/logStatus");
        bean.addInitParameter("key", "value");
        return bean;
    }

    /*
    在 WEB-INF/web.xml 中添加如下代码
    <servlet>
        <servlet-name>ViewStatusMessages</servlet-name>
        <servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ViewStatusMessages</servlet-name>
        <url-pattern>/lbClassicStatus</url-pattern>
    </servlet-mapping>
    */
}
